$(function () {
  var flag = true;
  var mainTop = $(".main").offset().top;
  console.log(mainTop);
  $(window).scroll(function () {
    if ($(document).scrollTop() >= mainTop) {
      $(".toolkit-list").fadeIn();
    } else {
      $(".toolkit-list").fadeOut();
    }
  });

  $(".card").hover(
    function () {
      $(this).css({ border: "1px solid orange", "background-color": "#fff" });
    },
    function () {
      $(this).css({ border: "1px solid #ccc", "background-color": "#f0f0f0" });
    }
  );
});

// 点击按钮，返回顶部
function backToTop() {
  document.body.scrollTop = 0;
  document.documentElement.scrollTop = 0;
}

window.onload = function () {
  if (sessionStorage.getItem("user_phone")) {
    $(".btn_login").css("display", "none");
    $(".btn_register").css("display", "none");
    $(".user-content").append("<div>欢迎您，随便逛逛吧！</div>");
    $("#exit").click(function () {
      sessionStorage.removeItem("user_phone");
      alert("退出成功！");
      window.location.href = "./index.html";
    });
  }
};
